﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.Drawing;

namespace HA.Data.DisplayOptions2
{

   
    [Serializable ]
    public class ContourLineTagging : ContourEventProperty, IObjectDataHelper, ICloneable 
    {


        //注意 ：修改字段后 需要修改运算符重载


        public ContourLineTagging()
        { 
        

        }



        bool _isShowTagging = true;
        /// <summary>
        /// 是否显示标注
        /// </summary>
        public bool IsShowTagging
        {
            get { return _isShowTagging; }
            set
            {
                if (_isShowTagging == value)
                {
                    return;
                }
                else
                {
                    _isShowTagging = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }


        Color _tagColor = Color.Black;
        /// <summary>
        /// 标注颜色
        /// </summary>
        public Color TagColor
        {
            get { return _tagColor; }
            set
            {
                if (_tagColor == value)
                {
                    return;
                }
                else
                {
                    _tagColor = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }


        int _fontSize = 5;
        /// <summary>
        /// 标注字体大小
        /// </summary>
        public int FontSize
        {
            get { return _fontSize; }
            set
            {
                if (_fontSize == value)
                {
                    return;
                }
                else
                {
                    _fontSize = value;
                    this.IsNeedUpdateData = true;
                }
                if (_fontSize <= 0)
                {
                    _fontSize = 1;
                }
            }
        }

        int _maskPointNum = 10;
        /// <summary>
        /// 采样点个数 最多多少个（标注最多多少个）
        /// </summary>
        public int MaskPointNum
        {
            get { return _maskPointNum; }
            set
            {
                if (_maskPointNum == value)
                {
                    return;
                }
                else
                {
                    _maskPointNum = value;
                    this.IsNeedUpdateData = true;
                }
                if (_maskPointNum <= 0)
                {
                    _maskPointNum = 1;
                }
            }
        }


        //int _decimalDigitNum = 3;
        ///// <summary>
        ///// 标注小数点位数
        ///// </summary>
        //public int DecimalDigitNum
        //{
        //    get { return _decimalDigitNum; }
        //    set { _decimalDigitNum = value; }
        //}


        //string _labelFormat = "%2g";
        ///// <summary>
        ///// 标注样式
        ///// </summary>
        //public string LabelFormat
        //{
        //    get { return _labelFormat; }
        //    set { _labelFormat = value; }
        //}


        #region 运算符重载


        public static bool operator ==(ContourLineTagging sp1, ContourLineTagging sp2)
        {

            if ((object)sp1 == null && (object)sp2 == null)
            {
                return true;
            }

            if (((object)sp1 == null && (object)sp2 != null) || ((object)sp1 != null && (object)sp2 == null))
            {
                return false;
            }

            if (sp1 != null && sp2 != null)
            {


                if (sp1._isShowTagging != sp2._isShowTagging)
                {
                    return false;
                }

                if (sp1._tagColor != sp2._tagColor)
                {
                    return false;
                }

                if (sp1._maskPointNum != sp2._maskPointNum)
                {
                    return false;
                }

                //if (sp1._decimalDigitNum != sp2._decimalDigitNum)
                //{
                //    return false;
                //}

                if (sp1._fontSize != sp2._fontSize)
                {
                    return false;
                }

                //if (sp1._labelFormat != sp2._labelFormat)
                //{
                //    return false;
                //}

            }

            return true;
        }

        public static bool operator !=(ContourLineTagging sp1, ContourLineTagging sp2)
        {
            return (!(sp1 == sp2));

        }


        #endregion



        #region IObjectDataHelper 成员

        public void ResetDataAndTriggerEvent(object obj)
        {

            if (obj == null)
            {
                return;

            }
            ContourLineTagging doContour = (ContourLineTagging)obj;

            //运算符重载   其根本还是遍历类中的所有字段进行了比较  
            if (doContour.IsDataChanged() == false)
            {
                return;
            }

            //更新副本数据到源数据   4个字段

            List<string> tagging = new List<string>();

            if (_isShowTagging !=doContour ._isShowTagging )
            { 
                _isShowTagging = doContour.IsShowTagging;

                tagging.Add(TaggingChangedType.TaggingSetup.ToString());
            }
            if (_tagColor != doContour._tagColor)
            {
                _tagColor = doContour._tagColor;
                tagging.Add(TaggingChangedType.TaggingSetup.ToString());
            }

            if (_fontSize !=doContour ._fontSize )
            { 
                _fontSize = doContour._fontSize;
                tagging.Add(TaggingChangedType.TaggingSetup.ToString());
            }


            if (_maskPointNum !=doContour ._maskPointNum )
            {
                 _maskPointNum = doContour._maskPointNum;
                 tagging.Add(TaggingChangedType.TaggingSetup.ToString());

            }




            if (tagging.Count > 0)
            {
                tagging.Clear();
                tagging.Add(TaggingChangedType.TaggingSetup.ToString());
            }


            if (tagging.Count > 0)
            {
                this.AskContourSetupChanged(new ContourSetupChangedEventArgs(this, ContourSetupChangedType.Tagging, tagging));


                //throw new NotImplementedException();
          
            }
        }

        public bool IsDataChanged()
        {
            if (this == null)
            {
                return false;
            }
            if (this.IsNeedUpdateData == true)
            {
                return true;
            }
            else
            {

                return false;
            }


            //throw new NotImplementedException();
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {



            ContourLineTagging obj = (ContourLineTagging)this.MemberwiseClone();




            return obj;





            //throw new NotImplementedException();
        }

        #endregion
    }


}
